﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// 
    /// </summary>
    public partial class ItemPurchaseApply
    {
        /// <summary>
        /// 组织机构
        /// </summary>
        private readonly ElingOA6_Admin_DSJCJ.DAL.ItemPurchaseApply dal = new ElingOA6_Admin_DSJCJ.DAL.ItemPurchaseApply();
        /// <summary>
        ///  获得数据列表
        /// <summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-9</date>
        /// </summary>
        /// <param name="dt">一张DataTable</param>
        /// <returns>返回Model</returns>
        public List<Model.ItemPurchaseApply> DataTableToListItemPurchaseApply(DataTable dt)
        {
            List<Model.ItemPurchaseApply> modelList = new List<Model.ItemPurchaseApply>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.ItemPurchaseApply model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.ItemPurchaseApply();
                    if (dt.Rows[n]["FItemPurchaseApplyID"] != null && dt.Rows[n]["FItemPurchaseApplyID"].ToString() != "")
                    {
                        model.FItemPurchaseApplyID = decimal.Parse(dt.Rows[n]["FItemPurchaseApplyID"].ToString());
                    }
                    if (dt.Rows[n]["FApplyDeptNo"] != null)
                    {
                        model.FApplyDeptNo = dt.Rows[n]["FApplyDeptNo"].ToString();
                    }
                    if (dt.Rows[n]["deptName"] != null)
                    {
                        model.DeptName = dt.Rows[n]["deptName"].ToString();
                    }
                    if (dt.Rows[n]["FEntityNo"] != null)
                    {
                        model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    }
                    if (dt.Rows[n]["FApplyEmplNo"] != null)
                    {
                        model.FApplyEmplNo = dt.Rows[n]["FApplyEmplNo"].ToString();
                    }
                    if (dt.Rows[n]["FEmpName"] != null)
                    {
                        model.FEmpName = dt.Rows[n]["FEmpName"].ToString();
                    }
                    if (dt.Rows[n]["FApplyReason"] != null)
                    {
                        model.FApplyReason = dt.Rows[n]["FApplyReason"].ToString();
                    }
                    if (dt.Rows[n]["FApplyDate"] != null && dt.Rows[n]["FApplyDate"].ToString() != "")
                    {
                        model.FApplyDate = DateTime.Parse(dt.Rows[n]["FApplyDate"].ToString());
                    }
                    if (dt.Rows[n]["FApplyIP"] != null)
                    {
                        model.FApplyIP = dt.Rows[n]["FApplyIP"].ToString();
                    }
                    if (dt.Rows[n]["FUpdDate"] != null && dt.Rows[n]["FUpdDate"].ToString() != "")
                    {
                        model.FUpdDate = DateTime.Parse(dt.Rows[n]["FUpdDate"].ToString());
                    }
                    if (dt.Rows[n]["FUpdIP"] != null)
                    {
                        model.FUpdIP = dt.Rows[n]["FUpdIP"].ToString();
                    }
                    if (dt.Rows[n]["FUpdEmplNo"] != null)
                    {
                        model.FUpdEmplNo = dt.Rows[n]["FUpdEmplNo"].ToString();
                    }
                    if (dt.Rows[n]["FStatus"] != null)
                    {
                        model.FStatus = dt.Rows[n]["FStatus"].ToString();
                    }
                    if (dt.Rows[n]["Cou"] != null)
                    {
                        model.Cou = dt.Rows[n]["Cou"].ToString();
                    }

                    modelList.Add(model);
                }
            }
            return modelList;
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="itemPurchaseApplyID">主键编号</param>
        /// <returns>得到一个对象实体</returns>
        public ElingOA6_Admin_DSJCJ.Model.ItemPurchaseApply GetModel(decimal itemPurchaseApplyID)
        {

            return dal.GetModel(itemPurchaseApplyID);
        }

        /// <summary>
        /// 增加数据
        /// </summary>
        /// <param name="model">ItemPurchaseApplyModel对象</param>
        /// <param name="entryModelList">entryModelList集合</param>
        /// <returns>增加</returns>
        public decimal Add(Model.ItemPurchaseApply model,List<Model.ItemPurchaseApplyEntry> entryModel)
        {
            return dal.Add(model, entryModel);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">ItemPurchaseApplyModel对象</param>
        /// <param name="entryModelList">entryModelList集合</param>
        public void Update(ElingOA6_Admin_DSJCJ.Model.ItemPurchaseApply model, List<Model.ItemPurchaseApplyEntry> entryModelList)
        {
            dal.Update(model, entryModelList);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="itemPurchaseApplyID">主键ID</param>      
        public void Delete(decimal itemPurchaseApplyID)
        {

            dal.Delete(itemPurchaseApplyID);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="itemPurchaseApplyIDArray">ID数组</param>
        public void ManyDelete(string[] itemPurchaseApplyIDArray)
        {
            dal.ManyDelete(itemPurchaseApplyIDArray);      
        }



        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Check(Model.ItemPurchaseApply model)
        {
            return dal.Check(model);
        }


    }
}
